/*
 * @Author: chentao 294446993@qq.com
 * @Date: 2022-12-23 10:41:34
 * @LastEditors: chentao 294446993@qq.com
 * @LastEditTime: 2023-01-30 10:27:08
 * @FilePath: \vue3-pc-app\src\store\modules\chat.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import {
  ADD_GROUP_MANAGER, BATCH_ADD_MANAGER,
  LIMIT_SELECT_MAX,
  BATCH_REMOVE_MANAGER,
  QUERY_GROUP_MANAGER_LIST,
  UPDATE_GROUP_MANAGER_LIST,
  FETCH_GROUP_MEMBER_LIST,
  UPDATE_G_MEMBER_LIST,
  CHECKED_VMODEL_ID_LIST,
  CHECKED_ITEM_RIGHT,
  CONFIRM_DISABLE,
  CHECKED_MANAGER_LIST,
  UPDATE_COPY_USER_FRIENDS,
  CHECKED_DEFAULT_FRIEND_LIST,
  SAVE_SEARCH_LAST_LIST,
  CHECKED_DEFAULT_LIST,
  UPDATE_BANNED_LIST,
  UPDATA_USER_GAG,
  ACTIVE_MSG_ITEM
} from '@/store/actiontypes'
const _groupUserMap = {};
const _groupInfoMap = {};
const _groupNoticeMap = {};

const state = {
  unreadMessageCount: 0, // 总的未读会话数量
  sessionList: [], // 会话列表
  friendList: [
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/6bdc90e0-66f0-4a24-8ea9-bcca37f8fc4e.jpg",
      "friendId": "d6e4b10959944852a010d0a811b94af4",
      "headImg": "",
      "nickname": "白国庆先进技术",
      "labelImg": "",
      "account": "53***399",
      "addFlag": true,
      "pinyin": "baiguoqingxianjinjishu"
    },
    {
      "friendStatus": 1,
      "img": "http://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "friendId": "03ba411ac4194c9fab87d7451eb93718",
      "headImg": "",
      "nickname": "刘德华",
      "labelImg": "",
      "account": "185****2158",
      "addFlag": true,
      "pinyin": "liudehua"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/016ec4cf-ce81-47b0-95eb-eafb79509823.png",
      "notes": "牛逼手机京东",
      "friendId": "2d4229161695481188aa0584eebd497b",
      "headImg": "",
      "nickname": "手机京东",
      "labelImg": "",
      "account": "165****9727",
      "addFlag": true,
      "pinyin": "niubishoujijingdong"
    },
    {
      "friendStatus": 1,
      "img": "http://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/2c747660-1cbe-41d6-be41-5d73c2c87b89.png",
      "friendId": "f097b2c88a9e4c3d82e3149976376d8b",
      "headImg": "",
      "nickname": "PLQ",
      "labelImg": "",
      "account": "737538***@qq.com",
      "addFlag": true,
      "pinyin": "PLQ"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/fcdead90-2a7d-4d77-9388-9418d657b521.jpg",
      "notes": "",
      "friendId": "41dcba4b5deb4b6bbab4fa3e10f3b100",
      "headImg": "",
      "nickname": "为什么",
      "labelImg": "",
      "account": "130****1307",
      "addFlag": true,
      "pinyin": "weishenme"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "notes": "yl",
      "friendId": "161b6aedcf2d4e44ba9d01afbb251ad4",
      "headImg": "",
      "nickname": "yl~*",
      "labelImg": "",
      "account": "a76554***@3202.com",
      "addFlag": true,
      "pinyin": "yl"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "friendId": "536814ee7ffe42df8166edd0a99afef7",
      "headImg": "",
      "nickname": "用户-B*6KX*",
      "labelImg": "",
      "account": "***@3202.com",
      "addFlag": true,
      "pinyin": "yonghu-B*6KX*"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "friendId": "0c0b0bbefdef466c8f15b31d09a91d27",
      "headImg": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/find/d1506c0f-eb27-405b-9aa6-9edf5bdb2b96.png",
      "nickname": "用户-BEGQW5",
      "labelImg": "",
      "account": "***@3202.com",
      "addFlag": true,
      "pinyin": "yonghu-BEGQW5"
    },
    {
      "friendStatus": 1,
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "friendId": "d85d73b03c7e4d75bba9114fd9994ab7",
      "headImg": "",
      "nickname": "用户-BX*5X*",
      "labelImg": "",
      "account": "e***@bccto.cc",
      "addFlag": true,
      "pinyin": "yonghu-BX*5X*"
    }
  ], // 好友列表
  groupList: [], // 群组列表
  userFriendNewUnprocessed: 0, // 未处理的好友请求数量
  friendApplicationList: [], // 好友请求列表

  currentSession: {}, // 当前会话

  groupMsgMap: {}, // 群组消息(用于最后一条消息的时间戳)
  currentGroupInfo: {}, // 当前会话群组的信息
  currentGroupNotice: {}, // 当前群组的公告信息
  groupMemberList: [
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/ff5675ee-7309-4f28-885f-cad9f1091a8f.jpg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "signature": "一个大神般的人",
      "isLeader": true,
      "groupUserTagImg": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/img/group_own.png",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 3791154,
      "userId": "5a375b8b1eec4492b2081a850db3b617",
      "nationality": "65,新加坡",
      "muteStatus": false,
      "nickname": "一点",
      "labelImg": "",
      "isManager": false,
      "isFriend": true
    },
    {
      "img": "https://aitd-block-1304418020.cos.ap-guangzhou.myqcloud.com/social_finance/user/image/ios/751C15F0-FFD5-4FDE-845B-51871CB7B069.jpeg",
      "notes": "产品经理-一流",
      "gender": 1,
      "headImg": "",
      "signature": "我是塔奇克马",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 1573311,
      "userId": "b4c6edf5dcf9488fa9b2e346eff02474",
      "nationality": "852,中国香港",
      "muteStatus": false,
      "nickname": "Tqkm~bato",
      "labelImg": "",
      "isManager": false,
      "isFriend": true
    },
    {
      "img": "https://aitd-block-1304418020.cos.ap-guangzhou.myqcloud.com/social_finance/user/image/ios/8DCB2605-B2BB-44F9-A6F8-D1E407ACA880.jpeg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 3793355,
      "userId": "b6be12d4999947a2aaa19c6f55ade71d",
      "nationality": "新加坡",
      "muteStatus": false,
      "nickname": "          小姐姐。  ",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/tribe/img/ios/DCEDA17D-12D7-43B7-B5C9-EB32BF7BC7C4.png",
      "notes": "",
      "gender": 0,
      "headImg": "",
      "signature": "所念皆星河",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 109271,
      "userId": "41dcba4b5deb4b6bbab4fa3e10f3b100",
      "nationality": "237,喀麦隆",
      "muteStatus": false,
      "nickname": "魅璃儿",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/b178c603-e639-49f3-b976-733b6c408279.jpg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 97184,
      "userId": "6c674ab638374087838d3f74b658ecc5",
      "nationality": "86,中國",
      "muteStatus": false,
      "nickname": "用户-97184",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-1304418020.cos.ap-guangzhou.myqcloud.com/social_finance/user/image/ios/5868CB7D-0EC8-4E84-A8C8-A7FB32D49BD3.jpeg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 1180448,
      "userId": "defc77a10ba44948a98ce44b1227744a",
      "nationality": "86,中國",
      "muteStatus": false,
      "nickname": "小哥哥",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-1304418020.cos.ap-guangzhou.myqcloud.com/social_finance/user/image/ios/2D45D5F3-3950-4D63-8641-08F966A456DC.jpeg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "signature": "一会就回去",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 3638082,
      "userId": "1caf7ca4d15146b3bf468df6cb1a10a1",
      "nationality": "新加坡",
      "muteStatus": false,
      "nickname": "Cris",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/87de857d-0f53-445e-8dfc-19dd7d1b4b3c.jpg",
      "notes": "",
      "gender": 0,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 3795924,
      "userId": "6ad380c6cad843d8b6ac46c33b206616",
      "nationality": "65,新加坡",
      "muteStatus": false,
      "nickname": "墨尔本的秋天",
      "labelImg": "",
      "isManager": false,
      "isFriend": true
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 3796744,
      "userId": "76234e699e504f62a9aa43e8136d0464",
      "nationality": "CN,中國",
      "muteStatus": false,
      "nickname": "chentao",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/insurance/8792de56-b5ae-40e2-a83b-eccbd43787c0.png",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 1787297,
      "userId": "9d192930a0a349d28087eadfb00f5886",
      "nationality": "65,新加坡",
      "muteStatus": false,
      "nickname": "大号qq-小号",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    },
    {
      "img": "https://aitd-block-image-public.s3.ap-southeast-1.amazonaws.com/social_finance/user/avatar/bb895d7b-6f34-42cf-bcb9-ba42243eb1a8.jpg",
      "notes": "",
      "gender": 1,
      "headImg": "",
      "signature": "郭佳",
      "isLeader": false,
      "groupUserTagImg": "",
      "groupId": 19036,
      "gnickname": "",
      "userSn": 109193,
      "userId": "bded098801834e04b4717e52eadc522d",
      "nationality": "297,阿鲁巴岛",
      "muteStatus": false,
      "nickname": "七零",
      "labelImg": "",
      "isManager": false,
      "isFriend": false
    }
  ], // 群组好友列表
  groupManagerList: [], //群管理员列表
  recallMsg: {}, // 撤回的消息
  messageRecords: {}, // 消息记录
  isSessionOver: true, //会话是否结束, 默认显示欢迎界面的
  selectFriendId: null, //还有列表选中的好友高亮

  limitMax: 0, //最大限制数
  msgRecordItem: {
    "id": 568,
    "messageId": "476a7186-d450-497d-bde5-7f6a9ea410d3",
    "sendType": "GROUP",
    "from": "41dcba4b5deb4b6bbab4fa3e10f3b100",
    "to": "2900",
    "messageType": "QX:TxtMsg",
    "timestamp": 1669533458567,
    "ignores": [

    ],
    "notice": null,
    "text": {
      "content": "😄😄😄😄😄😅😄😄😅😄😄😄😄😄😄😄😄😄😄😄",
      "extra": "",
      "atTos": []
    },
    "image": null,
    "imageText": null,
    "audio": null,
    "video": null,
    "file": null,
    "geo": null,
    "act": null,
    "vct": null,
    "stus": null,
    "custom": null,
    "recall": null,
    "remove": null,
    "reply": null,
    "record": null,
    "event": null,
    "audioRead": 0,
    "extra": null,
    "sendStatus": 3,
    "sendError": null,
    "isLastMsg": false,
    "createdDate": "2022-12-23T10:23:34.000Z",
    "updatedDate": "2022-12-23T10:23:34.000Z",
    "version": 1
  }
};

const Chat = {
  state,
  mutations: {

    //选中的消息item 
    [ACTIVE_MSG_ITEM](state, { msgRecordItem }) {
      state.msgRecordItem = msgRecordItem
    },
    //更新禁言名单
    [UPDATE_BANNED_LIST](state, { bannedList }) {
      state.bannedList = bannedList
    },
    //保存每次模糊搜索之前上一次的状态列表
    [SAVE_SEARCH_LAST_LIST](state, { saveSearchLastList }) {
      state.saveSearchLastList = saveSearchLastList
    },
    [CHECKED_DEFAULT_FRIEND_LIST](state, { checkedDefaultFriendList }) {
      state.checkedDefaultFriendList = checkedDefaultFriendList
    },
    [CHECKED_DEFAULT_LIST](state, { checkedDefaultList }) {
      state.checkedDefaultList = checkedDefaultList
    },
    [CONFIRM_DISABLE](state, { confirmDisable }) {
      state.confirmDisable = confirmDisable
    },
    //checkedItem的值设置
    [CHECKED_ITEM_RIGHT](state, { checkedItemRight }) {
      state.checkedItemRight = checkedItemRight
    },
    [CHECKED_VMODEL_ID_LIST](state, { checkedVmodelIdList }) {
      state.checkedVmodelIdList = checkedVmodelIdList
    },
    [CHECKED_MANAGER_LIST](state, { checkedManagerList }) {

      state.checkedManagerList = checkedManagerList
    },
    //最大选择数
    [LIMIT_SELECT_MAX](state, { limitMax }) {
      state.limitMax = limitMax
    },
    UPDATE_CURRENT_SESSION(state, value) {
      state.currentSession = value;
    },
    UPDATE_SESSION_LIST(state, value) {
      let _unreadMessageCount = 0;
      value.forEach((session) => {
        if (
          !session.isMuted &&
          state.currentSession.targetId != session.targetId
        ) {
          _unreadMessageCount += session.unreadMessageCount;
        }
      });
      state.unreadMessageCount = _unreadMessageCount;
      state.sessionList = value;
    },
    UPDATE_USER_FRIENDS(state, value) {
      state.friendList = value;
    },
    UPDATE_GROUP_LIST(state, value) {
      state.groupList = value;
    },
    [UPDATE_GROUP_MANAGER_LIST](state, { groupManagerList }) {
      state.groupManagerList = groupManagerList
    },
    UPDATE_USER_FRIEND_NEW_UNPROCESSED(state, value) {
      state.userFriendNewUnprocessed = value >= 0 ? value : 0;
    },
    UPDATE_USER_FRIEND_NEW(state, value) {
      state.friendApplicationList = value;
    },
    MODIFY_FRIEND_APPLICATION(state, { idx, isLoading, friendStatus }) {
      state.friendApplicationList[idx].isLoading = isLoading;
      state.friendApplicationList[idx].friendStatus = friendStatus;
    },
    DELETE_FRIEND_APPLICATION(state, targetId) {
      const idx = state.friendApplicationList.findIndex(
        (v) => v.friendId === targetId
      );
      if (idx !== -1) {
        const list = state.friendApplicationList;
        list.splice(idx, 1);
        state.friendApplicationList = list;
      }
    },
    // 删除会话
    DEL_CONVERSATION(state, targetId) {
      const idx = state.sessionList.findIndex((v) => v.targetId === targetId);
      if (idx !== -1) {
        const list = state.sessionList;
        list.splice(idx, 1);
        state.sessionList = list;
      }
    },
    //更新群成员副本列表
    [UPDATE_G_MEMBER_LIST](state, { gMemberList }) {
      state.gMemberList = [...gMemberList]
    },
    //更新群成员列表
    UPDATE_GROUP_MEMBER_LIST(state, value) {

      state.groupMemberList = value;
      //isLeader 过滤群主 
      state.limitMax = 0
      state.checkedDefaultList = []
      const gMemberList = value.filter((item) => {
        item.disabled = false
        if (item.isManager) {
          state.limitMax++
          item.disabled = true
          state.checkedDefaultList.push(item)
        }
        return item.isLeader !== true
      })
      //copy一份内存地址
      state.gMemberList = gMemberList
    },
    RECALL_MESSAGE(state, value) {
      const recallMsg = state.recallMsg ?? {};
      const mids = Object.keys(state.recallMsg);
      for (let i = 0; i < mids.length; i++) {
        const recallMsg = recallMsg[mids[i]];
        if (new Date().getTime() - recallMsg.timestamp > 600 * 1000) {
          delete recallMsg[mids[i]];
        }
      }
      recallMsg[value.messageId] = value;
      state.recallMsg = recallMsg;
    },
    UPDATE_CHAT_MSG_RECORDS(state, value) {
      state.messageRecords[value.targetId] = value.records;
    },
    APPEND_CHAT_MSG_RECORDS(state, value) {
      const records = state.messageRecords[value.targetId];
      state.messageRecords[value.targetId] = [].concat(
        records ?? [],
        value.records
      );
    },
    //会话是否结束/关闭会话
    UPDATE_IS_SESSION_OVER(state, value) {
      state.isSessionOver = value;
    },
    UPDATE_SELECT_FRIENDID(state, value) {
      state.selectFriendId = value;
    },
    UPDATE_CURRENT_GROUP_INFO(state, value) {
      state.currentGroupInfo = value;
    },
    UPDATE_CURRENT_GROUP_NOTICE(state, value) {
      state.currentGroupNotice = value;
    },
    UPDATE_GROUP_MSG_MAP(state, value) {
      state.groupMsgMap[parseInt(value.groupId)] = value.timestamp;
    },
    UPDATE_GROUP_MEMBER_MUTE_STATUS(state, value) {
      const _gm = state.groupMemberList.find(
        (gm) => gm.userId === value.userId
      );
      _gm.muteStatus = value.status;
    },
    UPDATE_GROUP_MEMBER_GNICK_NAME(state, value) {
      const _gm = state.groupMemberList.find(
        (gm) => gm.userId === value.userId
      );
      _gm.gnickname = value.nickName;
    },
  },
  actions: {
    UPDATE_GROUP_MSG_MAP({ commit }, { groupId, timestamp }) {
      commit("UPDATE_GROUP_MSG_MAP", { groupId, timestamp });
    },
    // 获取会话列表
    FETCH_SESSION_LIST({ commit }) {
      commit("UPDATE_SESSION_LIST", []);
    },
    // 获取用户好友列表
    FETCH_USER_FRIENDS({ commit }, forceRefresh = false) {
      commit("UPDATE_USER_FRIENDS", []);
    },
    //添加群管理员
    async [ADD_GROUP_MANAGER]({ commit, dispatch }, { groupId, userId }) {
      dispatch(QUERY_GROUP_MANAGER_LIST, {
        groupId: groupId,
        nickName: '',
      });
      dispatch(FETCH_GROUP_MEMBER_LIST, groupId)
      return res;
    },
    //批量添加管理员
    async [BATCH_ADD_MANAGER]({ }, { groupId, userIdList }) {
      console.log("群参数", userIdList, groupId)
      // dispatch(QUERY_GROUP_MANAGER_LIST, {
      //   groupId: groupId,
      //   nickName: '',
      // });
      // dispatch(FETCH_GROUP_MEMBER_LIST,groupId)
      return res;
    },
    //删除群管理员
    async [BATCH_REMOVE_MANAGER]({ dispatch }, { groupId, userIdList }) {

      // //刷新
      dispatch(QUERY_GROUP_MANAGER_LIST, {
        groupId: groupId,
        nickName: '',
      });
      dispatch(FETCH_GROUP_MEMBER_LIST, groupId)
    },
    //查询管理员列表
    async [QUERY_GROUP_MANAGER_LIST]({ commit, dispatch }, { groupId, nickName }) {
      let groupManagerList = []
      if (res && Array.isArray(res)) {
        groupManagerList = res
      }
      commit(UPDATE_GROUP_MANAGER_LIST, {
        groupManagerList
      });
      return res;
    },
    // 获取群组列表
    FETCH_GROUP_LIST({ commit }, forceRefresh = false) {
      commit("UPDATE_GROUP_LIST", []);
    },
    FETCH_USER_FRIEND_NEW_UNPROCESSED({ commit }) {

    },
    // 获取好友申请
    FETCH_USER_FRIEND_NEW({ commit }) {

    },
    // 标记已读
    TAG_READ_MESSAGE({ dispatch }, { sendType, targetId, lastTimestamp }) {
    },
    // 会话置顶
    SESSION_SET_TOP({ dispatch }, { sendType, targetId, type }) {

      dispatch("FETCH_SESSION_LIST");
    },
    // 会话免打扰
    SESSION_DISTURB({ dispatch }, { sendType, targetId, type }) {
      dispatch("FETCH_SESSION_LIST");
    },
    // 删除会话
    DEL_CONVERSATION({ dispatch, commit }, targetId) {
      commit("DEL_CONVERSATION", targetId);
      dispatch("FETCH_SESSION_LIST");
      commit("UPDATE_IS_SESSION_OVER", true);
    },
    // 删除消息
    DELETE_MESSAGE({ commit }, { sendType, targetId, messageIds, timestamp }) {

    },
    // 获取群组用户列表
    FETCH_GROUP_MEMBER_LIST({ commit }, groupId) {
      const list = _groupUserMap[groupId];
      commit("UPDATE_GROUP_MEMBER_LIST", list ?? []);
      commit("UPDATE_GROUP_MEMBER_LIST", list ?? []);
    },
    UPDATE_GROUP_MEMBER_MUTE_STATUS({ commit }, { userId, status }) {
      commit("UPDATE_GROUP_MEMBER_MUTE_STATUS", { userId, status });
    },
    UPDATE_GROUP_MEMBER_GNICK_NAME({ commit }, { userId, nickName }) {
      commit("UPDATE_GROUP_MEMBER_GNICK_NAME", { userId, nickName });
    },
    // 用户退出群组
    QUITE_GROUP({ dispatch, commit }, groupId) {
      // 删除会话
      dispatch("DEL_CONVERSATION", groupId);

    },
    // 用户批量退出群组(不包含群主)
    BATCH_QUITE_GROUP({ dispatch }, { groupId, userIds }) {

    },
    // 群组解散
    DISMISS_GROUP({ dispatch }, { groupId, userId }) {
      dispatch("FETCH_SESSION_LIST");
    },
    // 更新群组名称
    UPDATE_GROUP_NAME({ dispatch }, { id, name }) {
      dispatch("FETCH_SESSION_LIST");
    },
    // 撤回消息
    RECALL_MESSAGE({ dispatch, commit }, msg) {
      const data = {
        sendType: msg.sendType,
        targetId: msg.to,
        messageId: msg.messageId,
      };
      commit("RECALL_MESSAGE", msg);
    },
    // 获取群组信息
    FETCH_GROUP_INFO({ dispatch, commit }, groupId) {
      const info = _groupInfoMap[groupId];
      commit("UPDATE_CURRENT_GROUP_INFO", info ?? {});

    },
    // 获取群组公告
    FETCH_GROUP_NOTICE({ commit }, groupId) {
      const info = _groupNoticeMap[groupId];
      commit("UPDATE_CURRENT_GROUP_NOTICE", info ?? {});
      //   commit("UPDATE_CURRENT_GROUP_NOTICE", result);
    },
    UPDATE_CURRENT_SESSION({ commit }, value) {
      commit("UPDATE_CURRENT_SESSION", value);
    },
    FETCH_CHAT_MSG_RECORDS(
      { dispatch, commit },
      { sendType, targetId, timestamp }
    ) {
      //

    },
  },
};

export default Chat;
